﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vit.Database.Schema
{
    [Serializable]
    public class ForeignKeyColumnSchema : SchemaObjectBase
    {
        public string PrimaryTableColumnName { get; set; }
        public string ForeignTableColumnName { get; set; }

        private TableColumnSchema primaryTableColumn = null;
        public TableColumnSchema PrimaryTableColumn
        {
            get
            {
                return ForeignKeySchema.PrimaryTable.Columns.First(o => string.Equals(o.Name, this.PrimaryTableColumnName, StringComparison.OrdinalIgnoreCase));
            }
        }
        private TableColumnSchema foreignTableColumn = null;
        public TableColumnSchema ForeignTableColumn
        {
            get
            {
                return ForeignKeySchema.ForeignTable.Columns.First(o => string.Equals(o.Name, this.ForeignTableColumnName, StringComparison.OrdinalIgnoreCase));
            }
        }

        public ForeignKeySchema ForeignKeySchema
        {
            get;
            set;
        }
    }
}
